/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.aal.bean;

import com.aal.entity.Warehouse;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author quy
 */
@Stateless
public class WarehouseFacade extends AbstractFacade<Warehouse> implements WarehouseFacadeLocal {
    @PersistenceContext(unitName = "AAL-ejbPU")
    private EntityManager em;
      
    protected EntityManager getEntityManager() {
        return em;
    }

    public WarehouseFacade() {
        super(Warehouse.class);
    }

    @Override
    public List<Warehouse> findWarehouse(String warehouseName) {
        Query query = em.createNamedQuery("Warehouse.findByWarehouseName").setParameter("warehouseName",'%'+warehouseName+'%');
        return query.getResultList();
    }
    public Warehouse findName(String warehouseName){
        Query query = em.createNamedQuery("Warehouse.findByName").setParameter("warehouseName", warehouseName);
        return (Warehouse) query.getSingleResult();
    }
    
}
